fix(perps): prevent payment token reverting when switching in Pay With modal cp-7.66.0#26120
Conversation
…h modal Co-authored-by: Cursor <cursoragent@cursor.com>
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection: Key changes:
The changes are contained within the Perps feature area and interact with PerpsController. Following the tag description guidance:
This is a medium risk change because it modifies state management logic in a financial feature, but the changes are well-scoped and include comprehensive test coverage. Performance Test Selection: |
|



Description
When opening the Perps order view, the component syncs the transaction "pay token" from pending config (e.g. last selected payment token). The previous logic re-ran this sync on every effect run, so if the user changed the token in the "Pay With" modal, a later effect could overwrite their choice with the pending token again.
Changes:
initialAssetchanges). A ref tracks which pending token was already applied so we don’t overwrite the user’s in-session token selection.initialAssetchanges (e.g. user switches from BTC to ETH), the "applied" state is reset so pending config is re-applied for the new asset.setSelectedPaymentToken(null)is only called once, not on every effect run.This keeps the intended "restore from pending config" behavior on first load and on asset change, without undoing the user’s token choice when they’ve already changed it in the same session.
Changelog
CHANGELOG entry: Fixed Perps order view reverting the user’s payment token selection to the pending config after they had changed it in the Pay With modal.
Related issues
Jira issue: https://consensyssoftware.atlassian.net/browse/TAT-2572
Fixes: #26118
Manual testing steps
Screenshots/Recordings
Before
After
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-02-16.at.14.10.35.mov
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Low Risk
Small, localized state-sync change in a UI component with added unit tests; main risk is subtle regressions in when pending config is re-applied across rerenders/assets.
Overview
Fixes a Perps order flow bug where the pending trade configuration could repeatedly re-sync and revert the user’s payment token after they changed it in the Pay With modal.
PerpsPayRownow tracks (via refs) whether a pending payment token (or explicitnull) has already been applied, only applying it once per view load and resetting that applied state wheninitialAssetchanges so the correct pending token is re-applied per market. Tests were expanded to cover the “apply once”, “don’t overwrite after user switch”, “re-apply on asset change”, and “don’t re-null repeatedly” behaviors.Written by Cursor Bugbot for commit be0289a. This will update automatically on new commits. Configure here.